<!DOCTYPE html>
<html style="height: 100%;">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Log in</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.5 -->
    <link rel="stylesheet" href="/public/static/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="/public/static/css/font-awesome.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="/public/static/plugin/AdminLTE/css/AdminLTE.css">
    <![endif]-->
</head>
<body class="hold-transition login-page">
<div class="login-box">
    <div class="login-logo">
        <a href="http://www.dsp.com" target="_blank"><b>LogIn</b> Admin</a>
    </div><!-- /.login-logo -->
    <div class="login-box-body">
        <p class="login-box-msg">Sign in to start your session</p>
        <form id="login-form" action="?r=site/login" method="post">
            <div class="form-group has-feedback">
                <input type="input" name="user" class="form-control" placeholder="User">
                <span class="glyphicon glyphicon-user form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input type="password" name="password" class="form-control" placeholder="Password">
                <span class="glyphicon glyphicon-lock form-control-feedback"></span>
            </div>
            <div class="row">
                <div class="col-xs-8">
                </div><!-- /.col -->
                <div class="col-xs-4">
                    <button type="submit" class="btn btn-primary btn-block btn-flat">Sign In</button>
                </div><!-- /.col -->
            </div>
        </form>
    </div><!-- /.login-box-body -->
</div><!-- /.login-box -->

<!-- jQuery 2.1.4 -->
<script src="/public/static/js/jquery.min.js"></script>
<!-- Bootstrap 3.3.5 -->
<script src="/public/static/js/bootstrap.min.js"></script>

<script>
    $(function () {
        $("#login-form").submit(function(){
            var data = {
                'user'      : $(this).find('[name="user"]').val(),
                'password'  : $(this).find('[name="password"]').val()
            };
            var action = $(this).attr('action');

            $.get(action, data, function(rs){
                if(rs.state){
                    window.location.href = '/home/?r=site/game';
                }else{
                    alert(rs.msg || 'Login Error');
                }
            }, 'json');

            return false;
        });
    });
</script>
</body>
</html>
